package com.Servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.Servlet.Dao.usersEntity;

@WebServlet("/cMonneyToUserServlet")
public class cMonneyToUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("utf-8");
		response.setCharacterEncoding("utf-8");
		String money = request.getParameter("money");
		String userSno = request.getParameter("userSno");
		request.setAttribute("userSno", userSno);
		request.setAttribute("flag", "monney");
		request.setAttribute("cMonney", "false");
		try {
			if(usersEntity.enqury(userSno) != null) {
				usersEntity.changeMoney(userSno, money);
				request.setAttribute("cMonney", "true");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		request.getRequestDispatcher("Main.jsp").forward(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
